/** 
 * 别人的对话框
 */
class OtherTalk extends egret.Sprite {
    private num: number = 1;
    private txt: string = "别人的对话框";
    private face: string;
    constructor(num, txt, face?) {
        super();
        this.num = num;
        this.txt = txt;
        this.face = face;
        this.once(egret.Event.ADDED_TO_STAGE, this.init, this);
    }

    private init() {
        const header = Main.createBitmapByName(`header_${this.num}_png`);
        this.addChild(header);

        const bg = new egret.Bitmap();
        const talk = new eui.Label();
        const face = new egret.Bitmap();
        this.addChild(bg);
        this.addChild(talk);
        this.addChild(face);

        bg.x = header.width + 10;
        bg.texture = RES.getRes("otherTalk_png");

        talk.text = this.txt;
        talk.textColor = 0;
        talk.x = bg.x + 25;
        talk.y = 18;

        if (this.face) {
            face.texture = RES.getRes(this.face);
            face.x = talk.x + talk.width + 10;
            face.y = talk.y - 3;
        }

        bg.width = talk.width + 40 + face.width + 20;

        this.x = 20;
        this.y = Params.bufferTalk;
        Params.bufferTalk += this.height + 30;
    }
}